const {MongoClient}=require('mongodb')

const client=new MongoClient('mongodb://127.0.0.1:27017',{
    useNewUrlParser: true,
    useUnifiedTopology: true,
  })

async function run(){
    try {
        await client.connect()
        const testdb = client.db('test')
        const inventoryCollection=testdb.collection('inventory')
        const ret=await inventoryCollection.find()
        console.log(ret)
    } catch (err) {
        console.log('连接失败',err)
    }
    finally{
        await client.close()
    }
}
run()